<template>
  <section class="address_edit_wrapper">
    <c-nav-bar title="添加地址" />
    <van-address-edit
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </section>
</template>

<script>
import { defineComponent, ref } from "vue";
import { Toast } from 'vant';
export default defineComponent({
  setup() {
    const searchResult = ref([]);

    const onSave = () => Toast("save");
    const onDelete = () => Toast("delete");
    const onChangeDetail = (val) => {
      if (val) {
        searchResult.value = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区",
          },
        ];
      } else {
        searchResult.value = [];
      }
    };

    return {
      onSave,
      onDelete,
      searchResult,
      onChangeDetail,
    };
  },
});
</script>

<style lang="scss" scoped>
.address_edit_wrapper {
}
</style>
